package com.ff.neuropp.service;


import com.ff.neuropp.domain.Evaluation;
import com.ff.neuropp.repository.EvaluationRepository;
import com.ff.neuropp.util.ResultTool;
import org.springframework.expression.EvaluationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 评价服务
 */
@Service
public class AppEvaluateService {

    @Resource
    private EvaluationRepository evaluationRepository;


    /***
     * 新增评价
     * @param evaluation
     * @return
     */
    public Map<String,Object> addEvaluation(Evaluation evaluation){
        Evaluation out  = evaluationRepository.save(evaluation);
        return ResultTool.genSuccessResult(out);
    }

    /**
     * 评价信息
     * @param userId
     * @return
     */
    public Map<String,Object> evalutions(String userId){
        List<Evaluation>  list = new ArrayList<>();
        list  = evaluationRepository.findAllByUserId(userId);
        return ResultTool.genSuccessResult(list);
    }
}
